package me.yricky.alia.data.hierarchy

import me.yricky.alia.data.shape.Box
import me.yricky.alia.data.shape.Shape
import me.yricky.alia.data.shape.mergeBBox

/**
 * @author Yricky
 * @date 2022/1/27
 */

/**
 * 单个物理层的抽象，一个物理层上有很多图形。
 */
data class Layer(
    val id: LDPair,
    val shapes:List<Shape>
){
    data class LDPair(
        val layerId:Int,
        val dataTypeId:Int
    ) : Comparable<LDPair> {
        override fun compareTo(other: LDPair): Int {
            return if(layerId != other.layerId){
                layerId - other.layerId
            }else{
                dataTypeId - other.dataTypeId
            }
        }

        override fun toString(): String {
            return "LD($layerId/$dataTypeId)"
        }
    }

    val calcBBox: Box get() = mergeBBox(shapes.map { it.bBox })
}

